package com.example.card.smarthome.view;

import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.SearchViewCompat;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import com.example.card.smarthome.R;


/**
 * =============================================================================
 * Copyright (c) 2016 Card All rights reserved.
 * Packname com.example.card.smarthome.view
 * Created by Card.
 * Created time 2016/12/5 11:17.
 * Version   1.0;
 * Describe :
 * History:
 * ==============================================================================
 */

public class MainActivity extends AppCompatActivity {
    private Toolbar tools;
    private TextView tv_warn_one, tv_warn_two;
    private DrawerLayout mDrawerLayout;
    private CardView cv_temp, cv_concent, cv_clack, cv_home;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_slid);
        init();
        tools.setTitle("家居监控系统");

    }

    //初始化控件
    private void init() {
        Typeface font = Typeface.createFromAsset(getAssets(), "fontawesome-webfont.ttf");

        tools = (Toolbar) findViewById(R.id.tools);
        tools.inflateMenu(R.menu.menu_titlebar);
        tv_warn_one = (TextView) findViewById(R.id.tv_warn_one);
        tv_warn_two = (TextView) findViewById(R.id.tv_warn_two);
        mDrawerLayout = (DrawerLayout) findViewById(R.id.dl);
        cv_temp = (CardView) findViewById(R.id.cv_temperature);
        cv_concent = (CardView) findViewById(R.id.cv_concentration);
        cv_clack = (CardView) findViewById(R.id.cv_clack);
        cv_home = (CardView) findViewById(R.id.cv_home);

        tv_warn_one.setTypeface(font);
        tv_warn_two.setTypeface(font);

        cv_temp.setOnClickListener(cardListener);
        cv_concent.setOnClickListener(cardListener);
        cv_clack.setOnClickListener(cardListener);
        cv_home.setOnClickListener(cardListener);

        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, tools, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        mDrawerLayout.setDrawerListener(toggle);
        toggle.syncState();
    }

    public View.OnClickListener cardListener = new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            switch (view.getId()) {
                case R.id.cv_temperature:

                    break;
                case R.id.cv_concentration:

                    break;
                case R.id.cv_clack:

                    break;
                case R.id.cv_home:

                    break;
            }
        }
    };
}
